//
//  UIImage+Image.m
//  baisibudejie
//
//  Created by 陈博文 on 15/12/17.
//  Copyright © 2015年 陈博文. All rights reserved.
//

#import "UIImage+Image.h"

@implementation UIImage (Image)

+(instancetype)imageNameWithOriginalMode:(NSString *)imageName{
    
    UIImage *image = [UIImage imageNamed:imageName];
   image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    return image;
}


- (instancetype)bs_circleImage
{
    // 利用self生成一张圆形图片
    
    // 1.开启图形上下文
    UIGraphicsBeginImageContextWithOptions(self.size, NO, 0);
    
    // 2.描述圆形路径
    UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, self.size.width, self.size.height)];
    // 3.设置裁剪区域
    [path addClip];
    
    // 4.画图
    [self drawAtPoint:CGPointZero];
    
    // 5.取出图片
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    
    // 6.关闭上下文
    UIGraphicsEndImageContext();
    
    return image;
}

+ (instancetype)bs_circleImageNamed:(NSString *)name
{
    return [[UIImage imageNamed:name] bs_circleImage];
}

@end
